local skel = fk.CreateSkill{
  name = "knu_dushi",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["knu_dushi"] = "毒逝",
  [":knu_dushi"] = "锁定技，每个回合结束时，你弃置能使用或不能使用的所有手牌，并摸其中未包含花色数等量的牌。",

  ["#knu_dushi_ask"] = "毒逝：你弃置能使用或不能使用的所有手牌，并摸其中未包含花色数等量的牌",
  ["#knu_dushi_A"] = "可使用",
  ["#knu_dushi_B"] = "不可使用",

  ["$knu_dushi1"] = "忆昔东都年盛时，平生怨在帝王家。",
  ["$knu_dushi2"] = "殿饮鸩酒，含怨赋绝词。",
}

local U = require "packages/utility/utility"

skel:addEffect(fk.TurnEnd, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and not player:isKongcheng()
  end,
  on_use = function(self, event, target, player, data)
    local listA = {}
    local listB = {}
    for _,cid in ipairs(player:getCardIds("h")) do
      local c = Fk:getCardById(cid)
      if player:canUse(c) then
        table.insert(listA,cid)
      else
        table.insert(listB,cid)
      end
    end
    local listAll = {}
    if #listA == 0 then
      listAll = listB
    elseif #listB == 0 then
      listAll = listA
    else
      local choice = U.askForChooseCardList(player.room,player,{"#knu_dushi_A","#knu_dushi_B"},{listA,listB},1,1,skel.name,"#knu_dushi_ask",false,false)
      if choice[1] == "#knu_dushi_A" then
        listAll = listA
      else
        listAll = listB
      end
    end
    local suit = {}
    for _,cid in ipairs(listAll) do
      table.insertIfNeed(suit,Fk:getCardById(cid).suit)
    end
    player.room:throwCard(listAll,skel.name,player)
    if #suit < 4 then
      player.room:drawCards(player,4 - #suit,skel.name)
    end
  end,
})

return skel